﻿// ***********************************************************************
// Assembly         : STX.Lib
// Author           : seven.x
// Created          : 12-26-2013
//
// Last Modified By : seven.x
// Last Modified On : 11-26-2013
// ***********************************************************************
// <copyright file="StringExtensions.cs" company="驰创数码">
//     Copyright (c) 驰创数码. All rights reserved.
// </copyright>
// <summary></summary>
// ***********************************************************************
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

/// <summary>
/// The System namespace.
/// </summary>
namespace System
{
    /// <summary>
    /// Class StringExtensions.
    /// </summary>
    public static class StringExtensions
    {
        /// <summary>
        /// 检查字符串是否为空
        /// </summary>
        /// <param name="value">The value.</param>
        /// <returns><c>true</c> if [is null original empty] [the specified value]; otherwise, <c>false</c>.</returns>
        public static bool IsNullOrEmpty(this string value)
        {
            return string.IsNullOrEmpty(value);
        }

        /// <summary>
        /// 将字符串转为空
        /// </summary>
        /// <param name="value">The value.</param>
        /// <returns>A <see cref="System.String" /> that represents this instance.</returns>
        public static string ToString(this IEnumerable<int> value)
        {
            var enumerable = value as int[] ?? value.ToArray();
            if (value == null || enumerable.IsEmpty())
                return string.Empty;
            return string.Join(",", enumerable);
        }
         
        /// <summary>
        /// Joins the specified array.
        /// </summary>
        /// <param name="array">The array.</param>
        /// <param name="joinChar">The join character.</param>
        /// <returns>System.String.</returns>
        public static string Join(this string[] array, string joinChar)
        {
            return string.Join(joinChar, array);
        }
    }
}
